#include <bits/stdc++.h>

using namespace std;
typedef long long LL;
vector<int> primes{2, 3};

void init(int n) {
    //  primes.back()=7;
    for (int i = primes.back() + 2; i <= n; i += 2) {
        bool flag = true;
        for (auto p: primes) {
            if ( p * p > i )break;
            if ( i % p == 0 ) {
                flag = false;
                break;
            }
        }
        if ( flag )primes.push_back(i);
    }
}

LL phi(int n) {
    LL ret = n;
    for (int i = 2; i * i <= n; i++)
        if ( n % i == 0 ) {
            ret = ret / i * (i - 1);  //先进行除法防止溢出(ret=ret*(1-1/p(i)))
            while (n % i == 0) n /= i;
        }
    if ( n > 1 ) ret = ret / n * (n - 1);
    return ret;
}

int main() {
    int n;

    for (int n; cin >> n;) {
        init(n);
        vector<int> v(n + 1, 0);
        for (int i = 1; i <= n; i++)v[i] = phi(i);
        vector<int> s(n + 1, 0);
        partial_sum(v.begin(), v.end(), s.begin());
//        for (auto e:v)cout << e << " ";
//        cout << endl;
//        for (auto e:s)cout << e << " ";
//        cout << endl;

        LL tot = primes.size();
        for (int p: primes) {
            if ( p * 2 > n ) {
                continue;
            }
            tot += 2 * (s[n / p] - s[1]);
        }
        cout << tot << endl;

    }
    return 0;
}